//
//  UITextField+podding.m
//  Pods
//
//  Created by JM(jieson) on 16/3/4.
//
//

#import "UITextField+podding.h"
#import <objc/runtime.h>
@implementation UITextField (podding)
static char leftPadding_Key;

//- (instancetype)initWithCoder:(NSCoder *)coder
//{
//    self = [super initWithCoder:coder];
//    if (self) {
//        [self changeXib];
//    }
//    return self;
//}
//
//- (instancetype)initWithFrame:(CGRect)frame
//{
//    self = [super initWithFrame:frame];
//    if (self) {
//        [self changeXib];
//    }
//    return self;
//}
//
//- (void)changeXib {
//
//    
//}

- (NSUInteger)leftPadding {
    NSNumber *num = objc_getAssociatedObject(self, &leftPadding_Key);
    return num.unsignedIntegerValue;
}

- (void)setLeftPadding:(NSUInteger)leftPadding {
    NSNumber *num = @(leftPadding);
    objc_setAssociatedObject(self, &leftPadding_Key, num, OBJC_ASSOCIATION_COPY);
    self.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, leftPadding, 44)];
    self.leftViewMode = UITextFieldViewModeAlways;
}

//- (void)prepareForInterfaceBuilder {
//    NSLog(@"%s",__FUNCTION__);
//    
//#if !TARGET_INTERFACE_BUILDER
//    // this code will run in the app itself
//#else
//    // this code will execute only in IB
//#endif
//}
@end
